package com.jeff.tianti.cms.dao;

import com.jeff.tianti.cms.entity.ActivityAlerts;
import com.jeff.tianti.cms.entity.CnaaApplyFor;
import com.jeff.tianti.common.dao.CommonDao;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

/**
 * @author xujianfang
 * @desc ActivityAlertsDao�ӿ� 
 * @date 2019-07-11
 */
public interface ActivityAlertsDao extends ActivityAlertsDaoCustom,CommonDao<ActivityAlerts,String>{
    @Query(" from ActivityAlerts a where a.deleteFlag = 0 order by a.createDate desc ")
    Page<ActivityAlerts> findAllNoDel(Pageable pageable);

    @Query(" from ActivityAlerts a where a.deleteFlag = 0 and a.state = ?1 and a.type = ?2 order by a.sort desc,a.createDate desc")
    Page<ActivityAlerts> findByTo(String state, String type, Pageable pageable);

    @Query(" from ActivityAlerts a where a.deleteFlag = 0 and a.state = ?1 and a.type = ?2 order by time desc")
    Page<ActivityAlerts> findByToOrderByTime(String state, String type, Pageable pageable);

    @Query(" from ActivityAlerts a where sort = (select max(sort) from ActivityAlerts)")
    ActivityAlerts findMaxSort();
}